Skip to content

feat: add HTML landing page for SVG cards with robust content negotia… - #26

Merged
Chintanpatel24 merged 1 commit into
mainfrom
feat-landing-page-footer-1669454921884861657
Jun 11, 2026
Merged

feat: add HTML landing page for SVG cards with robust content negotia…#26
Chintanpatel24 merged 1 commit into
mainfrom
feat-landing-page-footer-1669454921884861657

Conversation

@Chintanpatel24

Copy link
Copy Markdown
Owner

…tion

Implement content negotiation in all API endpoints via a new sendResponse utility. This allows the same URL to serve a raw SVG when used in a GitHub README and a styled HTML landing page when a user clicks the card and opens it in a new tab.

Key features:

  • Robust detection of browser navigation using Sec-Fetch-Dest and Accept headers.
  • Specifically detects GitHub Camo proxy to ensure SVGs are always served in READMEs.
  • HTML landing page centers the SVG and adds a footer with the project reference.
  • Includes Vary: Accept, Sec-Fetch-Dest for correct CDN caching.
  • Supports ?format=svg query parameter to force raw SVG output.

Updated all 10 API endpoints to use this new utility.

…tion

Implement content negotiation in all API endpoints via a new `sendResponse` utility.
This allows the same URL to serve a raw SVG when used in a GitHub README and
a styled HTML landing page when a user clicks the card and opens it in a new tab.

Key features:
- Robust detection of browser navigation using `Sec-Fetch-Dest` and `Accept` headers.
- Specifically detects GitHub Camo proxy to ensure SVGs are always served in READMEs.
- HTML landing page centers the SVG and adds a footer with the project reference.
- Includes `Vary: Accept, Sec-Fetch-Dest` for correct CDN caching.
- Supports `?format=svg` query parameter to force raw SVG output.

Updated all 10 API endpoints to use this new utility.

Co-authored-by: Chintanpatel24 <216989679+Chintanpatel24@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 11, 2026 12:27
@vercel

vercel Bot commented Jun 11, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
gitlyy Ready Ready Preview, Comment Jun 11, 2026 12:27pm

@Chintanpatel24
Chintanpatel24 merged commit 9eb4640 into main Jun 11, 2026
5 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds request-context-based content negotiation so a single card endpoint can return either raw SVG (for embedding, proxies) or an HTML landing page (for browser navigation).

Changes:

  • Extends sendResponse to detect browser navigation via Sec-Fetch-Dest and Accept.
  • Adds ?format=svg override to force raw SVG output.
  • Updates caching behavior via Vary header for negotiated responses.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/response.js
Comment on lines +33 to +35
if (secFetchDest === "document") {
serveHtml = true;
}
Comment thread src/response.js
Comment on lines 38 to 40
res.setHeader("Content-Type", "text/html");
res.setHeader("Vary", "Accept");
res.setHeader("Vary", "Accept, Sec-Fetch-Dest");
const html = `
Comment thread src/response.js
Comment on lines 98 to 100
res.setHeader("Content-Type", "image/svg+xml");
res.setHeader("Vary", "Accept");
res.setHeader("Vary", "Accept, Sec-Fetch-Dest");
res.status(status).send(svg);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants